package com.hltx.service.user.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.hltx.mapper.user.UserFriendMapper;
import com.hltx.pojo.user.User;
import com.hltx.pojo.user.UserAccount;
import com.hltx.service.user_dubbo.UserFriendManager;

@Service (protocol = "dubbo", loadbalance = "roundrobin")
public class UserFriendService implements UserFriendManager {

	@Autowired
	private UserFriendMapper userFriendMapper;
	
	@Resource(name="sqlSessionFactory")
	private SqlSessionFactory factory;
	/**
	 * 获取上下级的取值范围
	 * @return
	 */
	@Override
	public Map<String, Map<String,String>> getSize() {
		return userFriendMapper.getSize();
	}

	/**
	 * 获取下级好友列表
	 */
	@Override
	public List<User> getMyFriendLowerList(int id) {
		return userFriendMapper.getMyFriendLowerList(id);
	}

	/**
	 * 获取当前用户的下级好友的个数
	 * @param id
	 * @return
	 */
	@Override
	public int getFriendCount(int id) {
		return userFriendMapper.getFriendCount(id);
	}

	/**
	 * 获取父id
	 * @param id
	 * @return
	 */
	@Override
	public Integer getParentId(int id) {
		return userFriendMapper.getParentId(id);
	}

	/**
	 * 获取用户的等级
	 * @param user
	 * @return
	 */
	@Override
	public String getUserLevel(User user) {
		return userFriendMapper.getUserLevel(user);
	}

	/**
	 * 获取所有的用户的等级
	 * @param user
	 * @return
	 */
	@Override
	public List<Map<String, Object>> getVIPLevelALL() {
		return userFriendMapper.getVIPLevelALL();
	}

	/**
	 * 获取用户的vipPrice
	 * @param user
	 * @return
	 */
	@Override
	public String getUserVipPrice(User user) {
		return userFriendMapper.getUserVipPrice(user);
	}

	/**
	 * 获取上级
	 * @return
	 */
	@Override
	public User getUserById(int parentId) {
		return userFriendMapper.getUserById(parentId);
	}

	/**
	 * 根据手机号   获取 上级的信息
	 */
	@Override
	public User getParentuser(String userNames) {
		return userFriendMapper.getParentuser(userNames);
	}
	
	@Override
	public User getParentByUserName(String userName) {
		// TODO Auto-generated method stub
		return userFriendMapper.getParentByUserName(userName);
	}
	
	/**
	 * 根据用户id获取用户信息
	 */
	@Override
	public UserAccount getUserAccount(int userId) {
		// TODO Auto-generated method stub
		return userFriendMapper.getUserAccount(userId);
	}
}
